<template>
  <div class="app-container">
    <!-- 页面标题区域 -->
    <div class="page-header">
      <div class="header-content">
        <div class="title-section">
          <i class="el-icon-user-solid header-icon"></i>
          <h2 class="page-title">团长注册申请管理</h2>
          <span class="page-subtitle">管理自提点申请、审核团长资质、分配配送区域</span>
        </div>
        <div class="header-actions">
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="medium"
            @click="handleAdd"
            v-hasPermi="['pickup-applications:pickup:add']"
            class="add-btn"
          >
            新增申请
          </el-button>
        </div>
      </div>
    </div>

    <!-- 搜索表单区域 -->
    <el-card class="search-card" shadow="hover">
      <div slot="header" class="search-header">
        <i class="el-icon-search"></i>
        <span>搜索条件</span>
        <el-button 
          type="text" 
          @click="toggleSearch"
          class="toggle-btn"
        >
          {{ showSearch ? '收起' : '展开' }}
          <i :class="showSearch ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
        </el-button>
      </div>
      
      <el-form 
        :model="queryParams" 
        ref="queryForm" 
        size="small" 
        :inline="true" 
        v-show="showSearch" 
        label-width="100px"
        class="search-form"
      >
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="申请人姓名" prop="applicantName">
              <el-input
                v-model="queryParams.applicantName"
                placeholder="请输入申请人姓名"
                clearable
                prefix-icon="el-icon-user"
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="申请人手机号" prop="applicantPhone">
              <el-input
                v-model="queryParams.applicantPhone"
                placeholder="请输入申请人手机号"
                clearable
                prefix-icon="el-icon-phone"
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="自提点名称" prop="pickupPointName">
              <el-input
                v-model="queryParams.pickupPointName"
                placeholder="请输入自提点名称"
                clearable
                prefix-icon="el-icon-office-building"
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="自提点地址" prop="pickupPointAddress">
              <el-input
                v-model="queryParams.pickupPointAddress"
                placeholder="请输入自提点地址"
                clearable
                prefix-icon="el-icon-location"
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="自提点类型" prop="pickupPointType">
              <el-select v-model="queryParams.pickupPointType" placeholder="请选择自提点类型" clearable>
                <el-option label="便利店" value="便利店" />
                <el-option label="超市" value="超市" />
                <el-option label="快递点" value="快递点" />
                <el-option label="其他" value="其他" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="申请时间" prop="applicationTime">
              <el-date-picker
                v-model="queryParams.applicationTime"
                type="date"
                placeholder="请选择申请时间"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="审核状态" prop="status">
              <el-select v-model="queryParams.status" placeholder="请选择审核状态" clearable>
                <el-option label="全部" value="" />
                <el-option label="待审核" value="pending" />
                <el-option label="已通过" value="approved" />
                <el-option label="已作废" value="rejected" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="审核人ID" prop="reviewerId">
              <el-input
                v-model="queryParams.reviewerId"
                placeholder="请输入审核人ID"
                clearable
                prefix-icon="el-icon-user-solid"
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="审核时间" prop="reviewTime">
              <el-date-picker
                v-model="queryParams.reviewTime"
                type="date"
                placeholder="请选择审核时间"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="创建时间" prop="createdAt">
              <el-date-picker
                v-model="queryParams.createdAt"
                type="date"
                placeholder="请选择创建时间"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="更新时间" prop="updatedAt">
              <el-date-picker
                v-model="queryParams.updatedAt"
                type="date"
                placeholder="请选择更新时间"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" class="search-btn">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" class="reset-btn">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>

    <!-- 操作按钮区域 -->
    <el-card class="action-card" shadow="hover">
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['pickup-applications:pickup:add']"
            class="action-btn add-btn"
          >新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['pickup-applications:pickup:edit']"
            class="action-btn edit-btn"
          >修改</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['pickup-applications:pickup:remove']"
            class="action-btn delete-btn"
          >删除</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['pickup-applications:pickup:export']"
            class="action-btn export-btn"
          >导出</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="success"
            plain
            icon="el-icon-check"
            size="mini"
            :disabled="multiple"
            @click="handleBatchApprove"
            v-hasPermi="['pickup-applications:pickup:audit']"
            class="action-btn approve-btn"
          >批量通过</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-close"
            size="mini"
            :disabled="multiple"
            @click="handleBatchReject"
            v-hasPermi="['pickup-applications:pickup:audit']"
            class="action-btn reject-btn"
          >批量作废</el-button>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
    </el-card>

    <!-- 状态标签页 -->
    <el-card class="tab-card" shadow="hover">
      <el-tabs v-model="activeTab" @tab-click="handleTabClick" class="status-tabs">
        <el-tab-pane label="待审核" name="pending">
          <span slot="label">
            <el-badge :value="pendingCount" :hidden="pendingCount === 0" class="tab-badge">
              待审核
            </el-badge>
          </span>
        </el-tab-pane>
        <el-tab-pane label="已通过" name="approved">
          <span slot="label">
            <el-badge :value="approvedCount" :hidden="approvedCount === 0" class="tab-badge">
              已通过
            </el-badge>
          </span>
        </el-tab-pane>
        <el-tab-pane label="已作废" name="rejected">
          <span slot="label">
            <el-badge :value="rejectedCount" :hidden="rejectedCount === 0" class="tab-badge">
              已作废
            </el-badge>
          </span>
        </el-tab-pane>
      </el-tabs>
    </el-card>

    <!-- 数据表格区域 -->
    <el-card class="table-card" shadow="hover">
      <el-table 
        v-loading="loading" 
        :data="pickupList" 
        @selection-change="handleSelectionChange"
        class="data-table"
        stripe
        border
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="申请ID" align="center" prop="applicationId" width="120" />
        <el-table-column label="申请人姓名" align="center" prop="applicantName" width="100" />
        <el-table-column label="申请人手机号" align="center" prop="applicantPhone" width="130" />
        <el-table-column label="自提点名称" align="center" prop="pickupPointName" width="150" />
        <el-table-column label="自提点地址" align="center" prop="pickupPointAddress" width="200" show-overflow-tooltip />
        <el-table-column label="自提点类型" align="center" prop="pickupPointType" width="100" />
        <el-table-column label="申请时间" align="center" prop="applicationTime" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.applicationTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="审核状态" align="center" prop="status" width="100">
          <template slot-scope="scope">
            <el-tag 
              :type="getStatusType(scope.row.status)"
              size="mini"
            >
              {{ getStatusText(scope.row.status) }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="审核人ID" align="center" prop="reviewerId" width="100" />
        <el-table-column label="审核时间" align="center" prop="reviewTime" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.reviewTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="审核备注" align="center" prop="reviewNotes" width="150" show-overflow-tooltip />
        <el-table-column label="创建时间" align="center" prop="createdAt" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createdAt, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="更新时间" align="center" prop="updatedAt" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updatedAt, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="handleView(scope.row)"
              class="operation-btn view-btn"
            >查看</el-button>
            <el-button
              v-if="scope.row.status === 'pending'"
              size="mini"
              type="text"
              icon="el-icon-check"
              @click="handleApprove(scope.row)"
              v-hasPermi="['pickup-applications:pickup:audit']"
              class="operation-btn approve-btn"
            >通过</el-button>
            <el-button
              v-if="scope.row.status === 'pending'"
              size="mini"
              type="text"
              icon="el-icon-close"
              @click="handleReject(scope.row)"
              v-hasPermi="['pickup-applications:pickup:audit']"
              class="operation-btn reject-btn"
            >作废</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['pickup-applications:pickup:edit']"
              class="operation-btn edit-btn"
            >修改</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['pickup-applications:pickup:remove']"
              class="operation-btn delete-btn"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>

    <!-- 添加或修改团长注册申请表对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body class="form-dialog">
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="申请人姓名" prop="applicantName">
              <el-input v-model="form.applicantName" placeholder="请输入申请人姓名" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="申请人手机号" prop="applicantPhone">
              <el-input v-model="form.applicantPhone" placeholder="请输入申请人手机号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="自提点名称" prop="pickupPointName">
              <el-input v-model="form.pickupPointName" placeholder="请输入自提点名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="自提点类型" prop="pickupPointType">
              <el-select v-model="form.pickupPointType" placeholder="请选择自提点类型" style="width: 100%">
                <el-option label="便利店" value="便利店" />
                <el-option label="超市" value="超市" />
                <el-option label="快递点" value="快递点" />
                <el-option label="其他" value="其他" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="自提点地址" prop="pickupPointAddress">
              <el-input v-model="form.pickupPointAddress" placeholder="请输入自提点地址" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="申请时间" prop="applicationTime">
              <el-date-picker
                v-model="form.applicationTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择申请时间"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核状态" prop="status">
              <el-select v-model="form.status" placeholder="请选择审核状态" style="width: 100%">
                <el-option label="待审核" value="pending" />
                <el-option label="已通过" value="approved" />
                <el-option label="已作废" value="rejected" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="审核人ID" prop="reviewerId">
              <el-input v-model="form.reviewerId" placeholder="请输入审核人ID" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核时间" prop="reviewTime">
              <el-date-picker
                v-model="form.reviewTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择审核时间"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="审核备注" prop="reviewNotes">
              <el-input 
                v-model="form.reviewNotes" 
                type="textarea" 
                placeholder="请输入审核备注"
                :rows="3"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" class="submit-btn">确 定</el-button>
        <el-button @click="cancel" class="cancel-btn">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listPickup, getPickup, delPickup, addPickup, updatePickup, approvePickup, rejectPickup, batchApprovePickup, batchRejectPickup } from "@/api/pickup-applications/pickup.js"

export default {
  name: "Pickup",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 团长注册申请表表格数据
      pickupList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        applicantName: null,
        applicantPhone: null,
        pickupPointName: null,
        pickupPointAddress: null,
        pickupPointType: null,
        applicationTime: null,
        status: null,
        reviewerId: null,
        reviewTime: null,
        createdAt: null,
        updatedAt: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        applicantName: [
          { required: true, message: "申请人姓名不能为空", trigger: "blur" }
        ],
        applicantPhone: [
          { required: true, message: "申请人手机号不能为空", trigger: "blur" }
        ],
        pickupPointName: [
          { required: true, message: "自提点名称不能为空", trigger: "blur" }
        ],
        pickupPointAddress: [
          { required: true, message: "自提点地址不能为空", trigger: "blur" }
        ],
        pickupPointType: [
          { required: true, message: "自提点类型不能为空", trigger: "change" }
        ]
      },
      // 当前激活的标签页
      activeTab: 'pending',
      // 各状态的数量统计
      pendingCount: 0,
      approvedCount: 0,
      rejectedCount: 0
    };
  },
  created() {
    // 根据当前激活的标签页设置查询条件
    this.queryParams.status = this.activeTab;
    this.getList();
    this.getStatusCounts();
  },
  methods: {
    /** 查询团长注册申请表列表 */
    getList() {
      this.loading = true
      listPickup(this.queryParams).then(response => {
        this.pickupList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        applicationId: null,
        applicantName: null,
        applicantPhone: null,
        pickupPointName: null,
        pickupPointAddress: null,
        pickupPointType: null,
        applicationTime: null,
        status: null,
        reviewerId: null,
        reviewTime: null,
        reviewNotes: null,
        createdAt: null,
        updatedAt: null
      }
      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      // 保持当前标签页的状态
      this.queryParams.status = this.activeTab;
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.applicationId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = "添加团长注册申请表"
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const applicationId = row.applicationId || this.ids
      getPickup(applicationId).then(response => {
        this.form = response.data
        this.open = true
        this.title = "修改团长注册申请表"
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.applicationId != null) {
            updatePickup(this.form).then(response => {
              this.$modal.msgSuccess("修改成功")
              this.open = false
              this.getList()
            })
          } else {
            addPickup(this.form).then(response => {
              this.$modal.msgSuccess("新增成功")
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const applicationIds = row.applicationId || this.ids
      this.$modal.confirm('是否确认删除团长注册申请表编号为"' + applicationIds + '"的数据项？').then(function() {
        return delPickup(applicationIds)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('pickup/pickup/export', {
        ...this.queryParams
      }, `pickup_${new Date().getTime()}.xlsx`)
    },
    // 搜索条件展开/收起
    toggleSearch() {
      this.showSearch = !this.showSearch
      if (!this.showSearch) {
        this.$nextTick(() => {
          this.$refs.queryForm.resetFields()
        })
      }
    },
    // 获取审核状态文本
    getStatusText(status) {
      switch (status) {
        case 'pending':
          return '待审核'
        case 'approved':
          return '已通过'
        case 'rejected':
          return '已作废'
        default:
          return '未知'
      }
    },
    // 获取审核状态类型
    getStatusType(status) {
      switch (status) {
        case 'pending':
          return 'info'
        case 'approved':
          return 'success'
        case 'rejected':
          return 'danger'
        default:
          return 'info'
      }
    },
    // 标签页切换
    handleTabClick(tab) {
      this.activeTab = tab.name;
      // 根据标签页设置状态查询条件
      if (tab.name === 'pending') {
        this.queryParams.status = 'pending';
      } else if (tab.name === 'approved') {
        this.queryParams.status = 'approved';
      } else if (tab.name === 'rejected') {
        this.queryParams.status = 'rejected';
      } else {
        this.queryParams.status = null; // 全部
      }
      this.getList();
    },
    // 查看申请详情
    handleView(row) {
      this.form = Object.assign({}, row);
      this.title = "查看申请详情";
      this.open = true;
    },
    // 审核通过
    handleApprove(row) {
      this.$prompt('请输入审核备注（可选）', '审核通过', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputType: 'textarea',
        inputPlaceholder: '请输入审核备注...'
      }).then(({ value }) => {
        this.approveApplication(row.applicationId, value);
      });
    },
    // 审核拒绝
    handleReject(row) {
      this.$prompt('请输入审核备注（必填）', '审核拒绝', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputType: 'textarea',
        inputPlaceholder: '请输入拒绝原因...',
        inputValidator: (value) => {
          if (!value || value.trim() === '') {
            return '审核备注不能为空';
          }
          return true;
        }
      }).then(({ value }) => {
        this.rejectApplication(row.applicationId, value);
      });
    },
    // 批量审核通过
    handleBatchApprove() {
      if (this.ids.length === 0) {
        this.$message.warning("请选择要审核的申请");
        return;
      }
      this.$prompt('请输入审核备注（可选）', '批量审核通过', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputType: 'textarea',
        inputPlaceholder: '请输入审核备注...'
      }).then(({ value }) => {
        this.batchApproveApplications(value);
      });
    },
    // 批量审核拒绝
    handleBatchReject() {
      if (this.ids.length === 0) {
        this.$message.warning("请选择要审核的申请");
        return;
      }
      this.$prompt('请输入审核备注（必填）', '批量审核拒绝', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputType: 'textarea',
        inputPlaceholder: '请输入拒绝原因...',
        inputValidator: (value) => {
          if (!value || value.trim() === '') {
            return '审核备注不能为空';
          }
          return true;
        }
      }).then(({ value }) => {
        this.batchRejectApplications(value);
      });
    },
    // 调用审核通过API
    approveApplication(applicationId, reviewNotes) {
      this.loading = true;
      approvePickup(applicationId, { reviewNotes }).then(response => {
        this.$modal.msgSuccess("审核通过成功");
        this.getList();
        this.getStatusCounts();
      }).catch(() => {
        this.loading = false;
      });
    },
    // 调用审核拒绝API
    rejectApplication(applicationId, reviewNotes) {
      this.loading = true;
      rejectPickup(applicationId, { reviewNotes }).then(response => {
        this.$modal.msgSuccess("审核拒绝成功");
        this.getList();
        this.getStatusCounts();
      }).catch(() => {
        this.loading = false;
      });
    },
    // 调用批量审核通过API
    batchApproveApplications(reviewNotes) {
      this.loading = true;
      batchApprovePickup(this.ids, { reviewNotes }).then(response => {
        this.$modal.msgSuccess("批量审核通过成功");
        this.getList();
        this.getStatusCounts();
        this.ids = [];
      }).catch(() => {
        this.loading = false;
      });
    },
    // 调用批量审核拒绝API
    batchRejectApplications(reviewNotes) {
      this.loading = true;
      batchRejectPickup(this.ids, { reviewNotes }).then(response => {
        this.$modal.msgSuccess("批量审核拒绝成功");
        this.getList();
        this.getStatusCounts();
        this.ids = [];
      }).catch(() => {
        this.loading = false;
      });
    },
    // 获取各状态的数量统计
    getStatusCounts() {
      // 这里可以调用API获取各状态的数量，暂时用模拟数据
      const pendingQuery = { status: 'pending' };
      const approvedQuery = { status: 'approved' };
      const rejectedQuery = { status: 'rejected' };
      
      // 获取待审核数量
      listPickup(pendingQuery).then(response => {
        this.pendingCount = response.total || 0;
      });
      
      // 获取已通过数量
      listPickup(approvedQuery).then(response => {
        this.approvedCount = response.total || 0;
      });
      
      // 获取已作废数量
      listPickup(rejectedQuery).then(response => {
        this.rejectedCount = response.total || 0;
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: calc(100vh - 84px);
}

/* 页面标题区域 */
.page-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  
  .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    .title-section {
      color: white;
      
      .header-icon {
        font-size: 32px;
        margin-right: 16px;
        vertical-align: middle;
      }
      
      .page-title {
        font-size: 28px;
        font-weight: 600;
        margin: 0 0 8px 0;
        display: inline-block;
        vertical-align: middle;
      }
      
      .page-subtitle {
        font-size: 14px;
        opacity: 0.9;
        margin: 0;
        display: block;
      }
    }
    
    .header-actions {
      .add-btn {
        background: rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.3);
        color: white;
        font-weight: 500;
        
        &:hover {
          background: rgba(255, 255, 255, 0.3);
          border-color: rgba(255, 255, 255, 0.4);
        }
      }
    }
  }
}

/* 搜索卡片 */
.search-card {
  margin-bottom: 20px;
  border-radius: 8px;
  
  .search-header {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: #303133;
    
    i {
      margin-right: 8px;
      color: #409eff;
    }
    
    .toggle-btn {
      margin-left: auto;
      color: #409eff;
      
      &:hover {
        color: #66b1ff;
      }
    }
  }
  
  .search-form {
    .el-form-item {
      margin-bottom: 16px;
    }
    
    .search-btn, .reset-btn {
      border-radius: 6px;
      font-weight: 500;
    }
  }
}

/* 操作按钮卡片 */
.action-card {
  margin-bottom: 20px;
  border-radius: 8px;
  
  .action-btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    
    &.add-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
    }
    
    &.edit-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(103, 194, 58, 0.3);
    }
    
    &.delete-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(245, 108, 108, 0.3);
    }
    
    &.export-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(230, 162, 60, 0.3);
    }
  }
}

/* 状态标签页 */
.tab-card {
  margin-bottom: 20px;
  border-radius: 8px;
  background-color: #fff;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);

  .status-tabs {
    .el-tabs__header {
      margin-bottom: 0;
      .el-tabs__nav-wrap::after {
        background-color: #ebeef5;
      }
      .el-tabs__item {
        font-size: 14px;
        font-weight: 600;
        color: #606266;
        &.is-active {
          color: #409eff;
        }
      }
      .el-tabs__active-bar {
        background-color: #409eff;
      }
    }
    .el-tabs__content {
      padding: 20px;
    }
  }

  .tab-badge {
    vertical-align: middle;
  }
}

/* 表格卡片 */
.table-card {
  border-radius: 8px;
  
  .data-table {
    .el-table__header {
      th {
        background-color: #fafafa;
        color: #606266;
        font-weight: 600;
      }
    }
    
    .el-table__row {
      &:hover {
        background-color: #f5f7fa;
      }
    }
  }
  
  .operation-btn {
    margin: 0 4px;
    border-radius: 4px;
    
    &.edit-btn:hover {
      color: #67c23a;
      background-color: rgba(103, 194, 58, 0.1);
    }
    
    &.delete-btn:hover {
      color: #f56c6c;
      background-color: rgba(245, 108, 108, 0.1);
    }
  }
}

/* 表单对话框 */
.form-dialog {
  .el-dialog__body {
    padding: 20px 30px;
  }
  
  .el-form-item {
    margin-bottom: 20px;
  }
  
  .dialog-footer {
    text-align: right;
    padding-top: 20px;
    border-top: 1px solid #ebeef5;
    
    .submit-btn {
      border-radius: 6px;
      font-weight: 500;
      margin-right: 12px;
    }
    
    .cancel-btn {
      border-radius: 6px;
      font-weight: 500;
    }
  }
}

/* 状态标签 */
.el-tag {
  border-radius: 4px;
  font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .search-form {
    .el-col {
      margin-bottom: 16px;
    }
  }
}

@media (max-width: 768px) {
  .page-header {
    padding: 16px;
    
    .header-content {
      flex-direction: column;
      text-align: center;
      
      .header-actions {
        margin-top: 16px;
      }
    }
  }
  
  .search-form {
    .el-col {
      width: 100% !important;
    }
  }
}
</style>
